package simpleftp.client.control;

import java.util.concurrent.Callable;

import simpleftp.client.gui.FTPClientWindow;




public final class Downloader implements Callable<Boolean> {

        private SimpleFTP client;
        private String server;
        private String port;
        private FTPClientWindow wind;
        private String user;
        private String pass;
        private String filename;

        public Downloader(String f, FTPClientWindow window, String server, String port,String user, String pass) 
        {
                        
                this.filename = f;
                this.server = server;
                this.port = port;
                this.wind = window;
                this.user = user;
                this.pass = pass;
                client = new SimpleFTP();
        }

        @Override
        public Boolean call() throws Exception {
               
                boolean result = false;
                client.connect(server, Integer.parseInt(port), user, pass);
                result = client.down(filename);
                if (result) {
                        wind.console.append("Successfully transfered file "
                                        + filename);                                             
                } else {
                        wind.console.append("Failed transfering file " + filename);
                                       }
                return result;
        }
}
